package lambda;

public class LambdaTest {

    //2.静态内部类
    static class Like2 implements  Like{
        @Override
        public void lambda() {
            System.out.println("like lambda2");
        }
    }

    public static void main(String[] args) {
        //3.局部内部类
        class Like3 implements Like{
            @Override
            public void lambda() {
                System.out.println("like lambda3");
            }
        }

        Like like = new Like1();
        like.lambda();

        like = new Like2();
        like.lambda();

        like = new Like3();
        like.lambda();

        //匿名内部类,没有类的名称
        like = new Like() {
            @Override
            public void lambda() {
                System.out.println("like lambda4");
            }
        };

        like.lambda();

        //lambda表达式
        like = ()->{
            System.out.println("like lambda5");
        };

        like.lambda();

    }
}

interface Like{
    public void lambda();
}

//1.外部实现类
class Like1 implements  Like{
    @Override
    public void lambda() {
        System.out.println("like lambda1");
    }
}
